home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
001-025
/
scopedisk8
/
asm
/
echo.lst
< prev
next >
Wrap
File List
|
1995-03-18
|
17KB
|
306 lines
** Asm68k 68000 Macro Assembler **
LINE PC CODE -----CARD------->
1 0000: ;
2 0000: ; Yet another ECHO .. Jim Butterfield, 1988Apr2
3 0000: ;
4 0000: ;- This is a CLI command only. Replaces ECHO 1.3 with NOLINE feature.
5 0000: ;- Usage: Echo [NOLINE] <string> ..or.. <string> [NoLine]
6 0000: ;
7 0000: ;- Quotes (") around the argument <string> are unnecessary
8 0000: ; unless you wish to have leading spaces or to type NOLINE,
9 0000: ; for example: Echo " Never say NoLine"
10 0000: ;
11 0000: ;- Asterisks are handled as follows:
12 0000: ; *n or *N - outputs a Newline (linefeed);
13 0000: ; *e or *E - outputs an Escape (chr${27});
14 0000: ; *[anything else] prints the character after asterisk,
15 0000: ; in particular:
16 0000: ; ** - outputs an asterisk;
17 0000: ; *" - outputs quotes (");
18 0000: ; Example: Echo Input**Output 2 3 4
19 0000: ; displays: Input*Output 2 3 4
20 0000: ; === Register Usage (* = used in system calls) ===
21 0000: ; *A0 - general pointer *D0 - general byte buffer
22 0000: ; *A1 - otherwise unused *D1 - otherwise unused
23 0000: ; A2 - output buf scan *D2 - output buf pointer
24 0000: ; A3 - input buf pointer *D3 - output length
25 0000: ; A4 - input scan ptr D4 - LINK pointer
26 0000: ; A5 - main scan ptr D5 - NOLINE flag
27 0000: ; A6 - library pointer D6 - asterisk flag, buffer
28 0000: ; A7 - gosh, I forget D7 - DOS output handle
29 0000:
30 0000: ;-- Symbolic equates:
31 0000: AbsExecBase equ $4 ; Loc of ptr to the
32 0000: ; Exec library.
33 0000: LF equ 10 ; Line Feed value.
34 0000: SPACE equ 32 ; Space char
35 0000: CASEmask equ %01011111 ; Mask to kill lower case.
36 0000: ;
37 0000: xref _LVOOpenLibrary ; These are Library routines referenced
38 0000: xref _LVOCloseLibrary ; externally by this program.
39 0000: xref _LVOOutput
40 0000: xref _LVOWrite
41 0000: xref _LVOInput
42 0000: xref _LVORead
43 0000: ;
44 0000: ; Save pointer and open DOS
45 0000:7A00 _main moveq #0,d5 ; clear noline flag
46 0002:2648 move.l a0,a3 ; pointer, input-buffer
47 0004:2A48 move.l a0,a5 ; work pointer
48 0006:43FA011A lea dosname(pc),a1
49 000A:4240 clr d0 ; Any version
50 000C:2C780004 move.l AbsExecBase,a6
51 0010:4EAE0000 jsr _LVOOpenLibrary(a6) ;Open Dos library.
52 0014:2C40 move.l d0,a6 ; Remember dosbase ptr.
53 0016:67000108 beq quit
54 001A: ;
55 001A: ;-- Get CLI outhandle:
** Asm68k 68000 Macro Assembler **
LINE PC CODE -----CARD------->
56 001A:4EAE0000 jsr _LVOOutput(a6) ; get CLI outhandle,
57 001E:2E00 move.l d0,d7 ; & then remember it.
58 0020: ; grab stack space
59 0020:4E54FF00 link a4,#-$100
60 0024:280C move.l a4,d4
61 0026:244F move.l a7,a2 ; pointer, output-buffer
62 0028: ; Check for ? sequence
63 0028:284D qspace move.l a5,a4
64 002A:0C1D0020 cmp.b #SPACE,(a5)+
65 002E:67F8 beq.s qspace
66 0030:2A4C move.l a4,a5
67 0032:0C1C003F cmp.b #$3F,(a4)+
68 0036:662C bne.s ljob
69 0038:0C14000A cmp.b #LF,(a4)
70 003C:6626 bne.s ljob
71 003E: ; Do the prompt thing
72 003E:41FA00F6 lea template(pc),a0
73 0042:2408 move.l a0,d2
74 0044:2207 move.l d7,d1
75 0046:263C00000011 move.l #templen,d3
76 004C:4EAE0000 jsr _LVOWrite(a6)
77 0050:4EAE0000 jsr _LVOInput(a6)
78 0054:2200 move.l d0,d1
79 0056:264A move.l a2,a3 ; switch input-buffer
80 0058:240B move.l a3,d2
81 005A:263C000000FF move.l #255,d3
82 0060:4EAE0000 jsr _LVORead(a6)
83 0064: ; Scan leading spaces and mebbe NOLINE
84 0064: ;
85 0064:2A4B ljob move.l a3,a5 ; input-buffer pointer
86 0066:284D lspace move.l a5,a4 ; first non-space
87 0068:0C1D0020 cmp.b #SPACE,(a5)+
88 006C:67F8 beq.s lspace ; space .. correct it
89 006E:2A4C move.l a4,a5
90 0070:4A05 tst.b d5 ; if we've found NOLINE..
91 0072:6618 bne.s nonoline1 ; ..don't search again
92 0074: ; search for NOLINE <space> at start
93 0074:41FA00B9 lea nolnstr(pc),a0
94 0078:101C nolinecklp move.b (a4)+,d0 ; text char
95 007A:0200005F andi.b #CASEmask,d0
96 007E:B018 cmp.b (a0)+,d0 ; NOLINE mask char
97 0080:660A bne.s nonoline1
98 0082:4A00 tst.b d0 ; <space> becomes $0
99 0084:66F2 bne.s nolinecklp ; if not space, back
100 0086: ; found NOLINE <space>
101 0086:7A01 moveq #1,d5 ; set NOLINE flag
102 0088:2A4C move.l a4,a5
103 008A:60DA bra.s lspace ; trim extra spaces
104 008C: ; scan to end of input, trim end spaces
105 008C:284D nonoline1 move.l a5,a4
106 008E:0C1C000A findend cmpi.b #LF,(a4)+ ; search for LF
107 0092:66FA bne.s findend
108 0094:193C0000 espace move.b #0,-(a4) ; change end to $0
109 0098:204C move.l a4,a0
110 009A:0C200020 cmp.b #SPACE,-(a0)
** Asm68k 68000 Macro Assembler **
LINE PC CODE -----CARD------->
111 009E:67F4 beq.s espace ; back through spaces
112 00A0:4A05 tst.b d5 ; if we've found NOLINE..
113 00A2:6618 bne.s nonoline2 ; ..don't search again
114 00A4: ; search for <space>NOLINE at end
115 00A4:41FA008F lea nolnstrend(pc),a0
116 00A8:1024 nolckloop move.b -(a4),d0 ; text char
117 00AA:0200005F andi.b #CASEmask,d0
118 00AE:B020 cmp.b -(a0),d0 ; NOLINE mask char
119 00B0:660A bne.s nonoline2
120 00B2:4A00 tst.b d0 ; <space> has become $0
121 00B4:66F2 bne.s nolckloop ; not space, try more.
122 00B6:7A01 moveq #1,d5 ; set NOLINE flag.
123 00B8:528C addq.l #1,a4
124 00BA:60D8 bra.s espace ; back to kill space(s).
125 00BC: ;
126 00BC: ;-- Start the argument line scanning process:
127 00BC:4283 nonoline2 clr.l d3 ; Clear output-chars count.
128 00BE:4206 clr.b d6 ; Clear asterisk flag.
129 00C0:240A move.l a2,d2
130 00C2: ;
131 00C2: ;-- Make new output line from argument line:
132 00C2:101D scan move.b (a5)+,d0 ; Get argument char.
133 00C4:67000036 beq exit ; Zero means we're finsihed.
134 00C8: ;
135 00C8: ;-- Check special chars flag:
136 00C8:4A06 tst.b d6 ; Check asterisk flag.
137 00CA:671A beq.s noastrsk ; No asterisk? Skip.
138 00CC: ;
139 00CC: ;-- Handle asterisk-plus-char:
140 00CC:1C00 move.b d0,d6
141 00CE:0206005F andi.b #CASEmask,d6 ; Kill lower case.
142 00D2:0C060045 cmpi.b #69,d6 ; Test for E
143 00D6:6604 bne.s try2
144 00D8:103C001B move.b #27,d0 ; E, substitute ESC
145 00DC:
146 00DC:0C06004E try2 cmpi.b #78,d6 ; Test for N
147 00E0:6612 bne.s putinbuf
148 00E2:103C000A move.b #LF,d0 ; N, substitute Newline
149 00E6: ;
150 00E6: ;-- Check for quote:
151 00E6:0C000022 noastrsk cmpi.b #'"',d0 ; If char is quote,
152 00EA:67D6 beq.s scan ; skip it.
153 00EC: ;
154 00EC: ;-- Check for asterisk:
155 00EC:7C01 moveq #1,d6
156 00EE:0C00002A cmpi.b #'*',d0 ; Is it '*'?
157 00F2:67CE beq.s scan ; Yes, log and get next char
158 00F4: ;
159 00F4: ;-- Put char in buffer:
160 00F4:4206 putinbuf clr.b d6 ; Clear Asterisk flag
161 00F6:14C0 move.b d0,(a2)+ ; Put char to output buffer.
162 00F8:5203 addq.b #1,d3 ; Increment outchar count.
163 00FA:60C6 bra.s scan ; Go for more input.
164 00FC: ;
165 00FC: ;-- After looking at all argument chars:
** Asm68k 68000 Macro Assembler **
LINE PC CODE -----CARD------->
166 00FC:4A05 exit tst.b d5 ; Check NOLINE flag.
167 00FE:6606 bne.s nolf
168 0100:14FC000A move.b #LF,(a2)+ ; If it's 0, put a linefeed at end.
169 0104:5203 addq.b #1,d3 ; & increment count to handle it.
170 0106:4A03 nolf tst.b d3
171 0108:67000008 beq close
172 010C: ; D2 and D3 already contain buffer address and size
173 010C:2207 move.l d7,d1 ; Outhandle
174 010E:4EAE0000 jsr _LVOWrite(a6) ; Print it!
175 0112: ;
176 0112: ;-- Unlink and close opened libraries:
177 0112:2844 close move.l d4,a4
178 0114:4E5C unlk a4
179 0116:224E move.l a6,a1 ; DOSBase to A1
180 0118:2C780004 move.l AbsExecBase,a6 ; Exec library...
181 011C:4EAE0000 jsr _LVOCloseLibrary(a6) ; close Dos library.
182 0120:4E75 quit rts ; Return control to CLI.
183 0122: ;
184 0122: ;-- Dos Library name:
185 0122:646F732E6C6962726172 dosname dc.b 'dos.library',0 ;name of Dos library
186 012E: ;-- NoLine keyword
187 012E:00 dc.b 0
188 012F:4E4F4C494E45 nolnstr dc.b 'NOLINE'
189 0135: nolnstrend equ *
190 0135:00 dc.b 0
191 0136: ;-- Template string:
192 0136:535452494E472C4E4F4C template dc.b 'STRING,NOLINE/S: '
193 0147: endtemp:
194 0147: templen EQU endtemp-template
195 0147:
Assembled Echo.asm to Echo.o
Object size = 327
No Errors detected
Free Ram used = 16384 Bytes
** Asm68k 68000 Macro Assembler **
Symbol Table:
AbsExecBase NUMBER 00000004
CASEmask NUMBER 0000005F
LF NUMBER 0000000A
SPACE NUMBER 00000020
_LVOCloseLibrary EXTERN
_LVOInput EXTERN
_LVOOpenLibrary EXTERN
_LVOOutput EXTERN
_LVORead EXTERN
_LVOWrite EXTERN
_main ? ADDRESS 00000000
close ADDRESS 00000112
dosname ADDRESS 00000122
endtemp ADDRESS 00000147
espace ADDRESS 00000094
exit ADDRESS 000000FC
findend ADDRESS 0000008E
ljob ADDRESS 00000064
lspace ADDRESS 00000066
noastrsk ADDRESS 000000E6
nolckloop ADDRESS 000000A8
nolf ADDRESS 00000106
nolinecklp ADDRESS 00000078
nolnstr ADDRESS 0000012F
nolnstrend NUMBER 00000135
nonoline1 ADDRESS 0000008C
nonoline2 ADDRESS 000000BC
putinbuf ADDRESS 000000F4
qspace ADDRESS 00000028
quit ADDRESS 00000120
scan ADDRESS 000000C2
template ADDRESS 00000136
templen NUMBER 00000011
try2 ADDRESS 000000DC
_main ? ADDRESS 00000000
AbsExecBase NUMBER 00000004
LF NUMBER 0000000A
templen NUMBER 00000011
SPACE NUMBER 00000020
qspace ADDRESS 00000028
CASEmask NUMBER 0000005F
ljob ADDRESS 00000064
lspace ADDRESS 00000066
nolinecklp ADDRESS 00000078
nonoline1 ADDRESS 0000008C
findend ADDRESS 0000008E
espace ADDRESS 00000094
** Asm68k 68000 Macro Assembler **
nolckloop ADDRESS 000000A8
nonoline2 ADDRESS 000000BC
scan ADDRESS 000000C2
try2 ADDRESS 000000DC
noastrsk ADDRESS 000000E6
putinbuf ADDRESS 000000F4
exit ADDRESS 000000FC
nolf ADDRESS 00000106
close ADDRESS 00000112
quit ADDRESS 00000120
dosname ADDRESS 00000122
nolnstr ADDRESS 0000012F
nolnstrend NUMBER 00000135
template ADDRESS 00000136
endtemp ADDRESS 00000147